import java.util.Scanner;

/**
 * @author gao
 * @date 2025/7/8 21:39
 */

public class Demo2 {
    private static int flag = 0;
    private static int count = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while (flag == 0) {
                count++;
                /*try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }*/
            }
            System.out.println("t1线程结束");
        });

        Thread t2 = new Thread(() -> {
            Scanner in = new Scanner(System.in);
            System.out.println("请输入flag的值:");
            flag = in.nextInt();
            System.out.println("t2线程结束");
        });

        t1.start();
        t2.start();

        t1.join();
        t2.join();
    }
}